﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApFLEXCableAttachmentViewModel
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;
using System.ComponentModel;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands;

public class CApFLEXCableAttachmentViewModel : INotifyPropertyChanged
{
  private CApFLEXAttachmentType m_attachmentType;
  private CApFLEXAttachmentLocation m_location;
  private double m_lengthFromStart;
  private double m_secondaryLengthFromStart;
  private CApFLEXRotatingAttachmentRotationAxis m_rotatingRotationAxis;
  private CApFLEXRotatingSlidingAttachmentRotationAxis m_rotatingSlidingRotationAxis;
  private double m_springConstant;
  private double m_minRetractedLength;
  private double m_maxRetractedLength;
  private ITxLocatableObject m_fixedFrame;
  private ITxLocatableObject m_secondaryFixedFrame;
  private bool m_isOkEnabled;
  private bool m_isEditableAttachment;
  private CApCableStatusMessageType m_attachmentStatusMessageType;
  private string m_attachmentMessage;
  private string m_attachmentTitle;
  private List<string> m_creationParametersNames;
  private List<string> m_selectionParametersNames;
  private Dictionary<string, bool> m_selectionParametersStatusDictionary;

  public CApFLEXCableAttachmentViewModel()
  {
    this.InitializeCreationParameters();
    this.InitializeSelectionParameters();
  }

  private void InitializeCreationParameters()
  {
    this.m_creationParametersNames = new List<string>(10)
    {
      "Location",
      "FixedFrame",
      "SecondaryFixedFrame",
      "LengthFromStart",
      "SecondaryLengthFromStart",
      "RotatingRotationAxis",
      "RotatingSlidingRotationAxis",
      "SpringConstant",
      "MinRetractedLength",
      "MaxRetractedLength"
    };
  }

  private void InitializeSelectionParameters()
  {
    this.m_selectionParametersNames = new List<string>(9)
    {
      "LocationSelected",
      "AttachmentFrameSelected",
      "SecondaryAttachmentFrameSelected",
      "DistanceFromStartSelected",
      "SecondaryDistanceFromStartSelected",
      "RotationAxisSelected",
      "SpringConstantSelected",
      "MinRetractedLengthSelected",
      "MaxRetractedLengthSelected"
    };
    this.m_selectionParametersStatusDictionary = new Dictionary<string, bool>(9);
    foreach (string selectionParametersName in this.m_selectionParametersNames)
      this.m_selectionParametersStatusDictionary.Add(selectionParametersName, false);
  }

  public CApFLEXAttachmentType AttachmentType
  {
    get => this.m_attachmentType;
    set
    {
      this.m_attachmentType = value;
      this.NotifyPropertyChanged(nameof (AttachmentType));
    }
  }

  public CApFLEXAttachmentLocation Location
  {
    get => this.m_location;
    set
    {
      this.m_location = value;
      this.NotifyPropertyChanged(nameof (Location));
    }
  }

  public ITxLocatableObject FixedFrame
  {
    get => this.m_fixedFrame;
    set
    {
      this.m_fixedFrame = value;
      this.NotifyPropertyChanged(nameof (FixedFrame));
    }
  }

  public ITxLocatableObject SecondaryFixedFrame
  {
    get => this.m_secondaryFixedFrame;
    set
    {
      this.m_secondaryFixedFrame = value;
      this.NotifyPropertyChanged(nameof (SecondaryFixedFrame));
    }
  }

  public double LengthFromStart
  {
    get => this.m_lengthFromStart;
    set
    {
      this.m_lengthFromStart = value;
      this.NotifyPropertyChanged(nameof (LengthFromStart));
    }
  }

  public double SecondaryLengthFromStart
  {
    get => this.m_secondaryLengthFromStart;
    set
    {
      this.m_secondaryLengthFromStart = value;
      this.NotifyPropertyChanged(nameof (SecondaryLengthFromStart));
    }
  }

  public CApFLEXRotatingAttachmentRotationAxis RotatingRotationAxis
  {
    get => this.m_rotatingRotationAxis;
    set
    {
      this.m_rotatingRotationAxis = value;
      this.NotifyPropertyChanged(nameof (RotatingRotationAxis));
    }
  }

  public CApFLEXRotatingSlidingAttachmentRotationAxis RotatingSlidingRotationAxis
  {
    get => this.m_rotatingSlidingRotationAxis;
    set
    {
      this.m_rotatingSlidingRotationAxis = value;
      this.NotifyPropertyChanged(nameof (RotatingSlidingRotationAxis));
    }
  }

  public double SpringConstant
  {
    get => this.m_springConstant;
    set
    {
      this.m_springConstant = value;
      this.NotifyPropertyChanged(nameof (SpringConstant));
    }
  }

  public double MaxRetractedLength
  {
    get => this.m_maxRetractedLength;
    set
    {
      this.m_maxRetractedLength = value;
      this.NotifyPropertyChanged(nameof (MaxRetractedLength));
    }
  }

  public double MinRetractedLength
  {
    get => this.m_minRetractedLength;
    set
    {
      this.m_minRetractedLength = value;
      this.NotifyPropertyChanged(nameof (MinRetractedLength));
    }
  }

  public bool IsEditableAttachment
  {
    get => this.m_isEditableAttachment;
    set
    {
      this.m_isEditableAttachment = value;
      this.NotifyPropertyChanged(nameof (IsEditableAttachment));
    }
  }

  public bool IsOkEnabled
  {
    get => this.m_isOkEnabled;
    set
    {
      this.m_isOkEnabled = value;
      this.NotifyPropertyChanged(nameof (IsOkEnabled));
    }
  }

  public CApCableStatusMessageType AttachmentStatusMessageType
  {
    get => this.m_attachmentStatusMessageType;
    set
    {
      this.m_attachmentStatusMessageType = value;
      this.NotifyPropertyChanged(nameof (AttachmentStatusMessageType));
    }
  }

  public string AttachmentMessage
  {
    get => this.m_attachmentMessage;
    set
    {
      this.m_attachmentMessage = value;
      this.NotifyPropertyChanged(nameof (AttachmentMessage));
    }
  }

  public string AttachmentTitle
  {
    get => this.m_attachmentTitle;
    set
    {
      this.m_attachmentTitle = value;
      this.NotifyPropertyChanged(nameof (AttachmentTitle));
    }
  }

  public bool IsCreationParameter(string eProperty)
  {
    bool flag = false;
    for (int index = 0; !flag && index < this.m_creationParametersNames.Count; ++index)
    {
      if (eProperty == this.m_creationParametersNames[index])
        flag = true;
    }
    return flag;
  }

  public void AttachmentViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
  {
    if (!(e.PropertyName == "LengthFromStart"))
      return;
    this.NotifyPropertyChanged("AttachmentDataList");
  }

  public void SetLengthFromStartNoEventSent(double value) => this.m_lengthFromStart = value;

  public void SetSecondaryLengthFromStartNoEventSent(double value)
  {
    this.m_secondaryLengthFromStart = value;
  }

  public void SetSpringConstantNoEventSent(double value) => this.m_springConstant = value;

  public void SetMinRetractedLengthNoEventSent(double value) => this.m_minRetractedLength = value;

  public void SetMaxRetractedLengthNoEventSent(double value) => this.m_maxRetractedLength = value;

  public bool LocationSelected
  {
    get => this.GetSelectionStatus(nameof (LocationSelected));
    set => this.SetSelectionStatus(nameof (LocationSelected), value);
  }

  public bool AttachmentFrameSelected
  {
    get => this.GetSelectionStatus(nameof (AttachmentFrameSelected));
    set => this.SetSelectionStatus(nameof (AttachmentFrameSelected), value);
  }

  public bool SecondaryAttachmentFrameSelected
  {
    get => this.GetSelectionStatus(nameof (SecondaryAttachmentFrameSelected));
    set => this.SetSelectionStatus(nameof (SecondaryAttachmentFrameSelected), value);
  }

  public bool DistanceFromStartSelected
  {
    get => this.GetSelectionStatus(nameof (DistanceFromStartSelected));
    set => this.SetSelectionStatus(nameof (DistanceFromStartSelected), value);
  }

  public bool SecondaryDistanceFromStartSelected
  {
    get => this.GetSelectionStatus(nameof (SecondaryDistanceFromStartSelected));
    set => this.SetSelectionStatus(nameof (SecondaryDistanceFromStartSelected), value);
  }

  public bool RotationAxisSelected
  {
    get => this.GetSelectionStatus(nameof (RotationAxisSelected));
    set => this.SetSelectionStatus(nameof (RotationAxisSelected), value);
  }

  public bool SpringConstantSelected
  {
    get => this.GetSelectionStatus(nameof (SpringConstantSelected));
    set => this.SetSelectionStatus(nameof (SpringConstantSelected), value);
  }

  public bool MinRetractedLengthSelected
  {
    get => this.GetSelectionStatus(nameof (MinRetractedLengthSelected));
    set => this.SetSelectionStatus(nameof (MinRetractedLengthSelected), value);
  }

  public bool MaxRetractedLengthSelected
  {
    get => this.GetSelectionStatus(nameof (MaxRetractedLengthSelected));
    set => this.SetSelectionStatus(nameof (MaxRetractedLengthSelected), value);
  }

  private bool GetSelectionStatus(string inputParameterName)
  {
    return this.m_selectionParametersStatusDictionary[inputParameterName];
  }

  private void SetSelectionStatus(string inputParameterName, bool status)
  {
    this.m_selectionParametersStatusDictionary[inputParameterName] = status;
    if (this.m_selectionParametersStatusDictionary[inputParameterName])
    {
      foreach (string selectionParametersName in this.m_selectionParametersNames)
      {
        if (selectionParametersName != inputParameterName)
        {
          this.m_selectionParametersStatusDictionary[selectionParametersName] = false;
          this.NotifyPropertyChanged(selectionParametersName);
        }
      }
    }
    this.NotifyPropertyChanged(inputParameterName);
  }

  public void ClearSelectionStatus()
  {
    foreach (string selectionParametersName in this.m_selectionParametersNames)
    {
      this.m_selectionParametersStatusDictionary[selectionParametersName] = false;
      this.NotifyPropertyChanged(selectionParametersName);
    }
  }

  public event PropertyChangedEventHandler PropertyChanged;

  protected void NotifyPropertyChanged(string info)
  {
    PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
    if (propertyChanged == null)
      return;
    propertyChanged((object) this, new PropertyChangedEventArgs(info));
  }
}
